import random
import requests

https = [
    {'https': '223.19.212.30:8380'},
    {'https': '221.19.212.30:8380'}
]
http = [
    {'http': '223.19.212.30:8380'},
    {'http': '221.19.212.30:8380'}
]

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'
}
url = 'https://www.baidu.com/s?wd=ip'

if url.split(':')[0] == 'https':
    page_text = requests.get(url=url, headers=headers, proxies=random.choice(https)).text
else:
    page_text = requests.get(url=url, headers=headers, proxies=random.choice(http)).text

with open('./ip.html', 'w', encoding='utf-8') as fp:
    fp.write(page_text)
